package uf.tax.laws.spider.sd;

import uf.tax.laws.spider.HttpDAO;

/**
 * 登录税务网
 * 
 * @author sunny
 *
 */
public class Login {
	private HttpDAO http;

	public Login(HttpDAO http) {
		this.http = http;
	}

	public boolean login(String name, String password) throws Exception {
		// http://www.taxad.cn/include/ChkLogin.aspx?name=whxy001&pass=123456&logauto=0
		http.get("http://www.taxad.cn/");
		// List<NameValuePair> nvps = new ArrayList<NameValuePair>();
		// nvps.add(new BasicNameValuePair("name", name));
		// nvps.add(new BasicNameValuePair("pass", password));
		// nvps.add(new BasicNameValuePair("logauto", "0"));
		// String contentString = http.httpPost(
		// "http://www.taxad.cn/include/ChkLogin.aspx", nvps);
		// 这个破网站，参数居然按照顺序来读取，真是lower
		String contentString = http
				.get(String
						.format("http://www.taxad.cn/include/ChkLogin.aspx?name=%s&pass=%s&logauto=0",
								name, password));
		System.out.println("return: " + contentString);
		return contentString.trim().equalsIgnoreCase("true");
	}

}
